<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="年份" prop="years">
        <el-date-picker
          v-model="queryParams.years"
          value-format="YYYY"
          type="year"
          placeholder="选择年份"
          clearable
          class="!w-240px"
        />
      </el-form-item>
      <el-form-item label="季度" prop="quarter">
        <el-select
          v-model="queryParams.quarter"
          placeholder="请选择季度"
          clearable
          class="!w-240px"
        >
          <el-option label="第一季度" :value="1" />
          <el-option label="第二季度" :value="2" />
          <el-option label="第三季度" :value="3" />
          <el-option label="第四季度" :value="4" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
      </el-form-item>
    </el-form>
  </ContentWrap>

  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="年份" align="center" prop="years" width="100" />
      <el-table-column label="季度" align="center" prop="quarter" width="100">
        <template #default="scope">
          第{{ scope.row.quarter }}季度
        </template>
      </el-table-column>
      <el-table-column label="员工姓名" align="center" prop="userName" min-width="120" />
      <el-table-column label="考核奖金基准金额" align="center" prop="baseBonusAmount" min-width="150" />
      <el-table-column label="考核总分" align="center" prop="totalScore" min-width="120" />
      <el-table-column label="季度奖金金额" align="center" prop="quarterlyBonusAmount" min-width="150" />
      <el-table-column label="备注" align="center" prop="remarks"  />
      <el-table-column label="状态" align="center" prop="status" min-width="100">
        <template #default="scope">
          <el-tag :type="scope.row.status === 1 ? 'success' : 'warning'">
            {{ scope.row.status === 1 ? '已发布' : '未发布' }}
          </el-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180px"
      /> -->
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>
</template>

<script setup lang="ts">
import { EmployeeQuarterlyAssessmentApi, EmployeeQuarterlyAssessmentVO } from '@/api/oa/employeequarterlyassessment'

/** 个人季度考核 列表 */
defineOptions({ name: 'MyEmployeeQuarterly' })

const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const list = ref<EmployeeQuarterlyAssessmentVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  years: undefined,
  quarter: undefined,
  status: 1 // 只查看已发布的
})
const queryFormRef = ref() // 搜索的表单

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await EmployeeQuarterlyAssessmentApi.getMyEmployeeQuarterlyAssessmentPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}

/** 初始化 **/
onMounted(() => {
  getList()
})
</script>
